package com.dnjn.happiness.system.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.common.core.model.TeamVo;
import com.dnjn.happiness.system.api.RemoteSiteService;
import com.dnjn.happiness.system.api.RemoteTeamService;
import com.dnjn.happiness.system.api.domain.SysTeam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class RemoteTeamFallbackFactory implements FallbackFactory<RemoteTeamService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteTeamFallbackFactory.class);

    @Override
    public RemoteTeamService create(Throwable throwable) {
        log.error("调用人员架构服务失败：{}" + throwable.getMessage());
        return new RemoteTeamService() {
            @Override
            public void updateAppraiseTime(Long userId, String source) {
                log.error("更新评价时间失败: {}" + userId);
            }

            @Override
            public R<List<Long>> getChildList(Long teamId, String source) {
                return R.fail("getChildList 查询人员架构失败: {}" + throwable.getMessage());
            }

            @Override
            public void updateTeamCheckTimeByUserId(Long userId, String source) {
                log.error("更新考核时间失败: {}" + userId);
            }

            @Override
            public R<SysTeam> getMangerUpOne(Long userId, String source) {
                return R.fail("getMangerUpOne 查询人员架构失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<SysTeam>> getSubordinate(Long userId, String source) {
                return R.fail("getSubordinate 查询人员架构列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<SysTeam>> getManager(Long userId, String source) {
                return R.fail("getManager 查询人员架构列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<SysTeam>> getLeaderList(List<SysTeam> sysTeams, String source) {
                return R.fail("getLeaderList 查询人员架构列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<SysTeam>> getEmployees(List<SysTeam> sysTeams, String source) {
                return R.fail("getEmployees 查询人员架构列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<List<SysTeam>> getLeaderListBydeptId(Long deptId, String source) {
                return R.fail("getLeaderListBydeptId 根据部门id查询人员架构列表失败: {}" + throwable.getMessage());
            }

            @Override
            public R<SysTeam> getParentInfoByUserId(Long userId, String source) {
                return R.fail("根据用户id查询父级人员架构信息失败: {}" + throwable.getMessage());
            }

            @Override
            public R<SysTeam> getInfoById(Long userId, String source) {
                return R.fail("根据用户id查询人员架构失败: {}" + throwable.getMessage());
            }

            @Override
            public R<SysTeam> queryInfoByTeamId(Long teamId, String source) {
                return R.fail("根据teamId查询人员架构失败: {}" + throwable.getMessage());
            }
        };
    }
}
